<?php
require_once('config.php');
require_once('../congo-sso/OauthClient.php');

$uri = trim($_SERVER['REQUEST_URI'], '/');

if (strpos($uri, 'ticket') === 0) {
    // 应用的appKey，应用的密钥,由开放平台发放
    $oauthClient = new \CongoSSO\OAuthClient($APP_KEY, $SECRET_KEY);
    // 应用客户端部署地址
    $oauthClient->setSSOClientServerUrl($SSO_CLIENT_SERVER);

    // Get token
    $result = $oauthClient->getTokenByTicket($_GET['ticket']);
    header('Content-Type:application/json; charset=utf-8');
    exit(json_encode($result));
} else {
    exit('success');
}
?>
